home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-03 | 1.6 KB | 94 lines | [TEXT/CWIE] |
- unit MySpeak;
-
- interface
-
- uses
- Types;
-
- procedure StartupSpeak;
- function SpeakBusy: boolean;
- procedure SpeakStr (s: Str255);
- procedure Speak(id, index: integer);
- function SpeechAvailable: boolean;
-
- implementation
-
- uses
- Speech, GestaltEqu, TextUtils, CodeFragments, OSUtils,
- MyStartup;
-
- {$ifc do_debug}
- var
- startup_check: integer;
- {$endc}
-
- {$SETC debug=0}
-
- function HasSpeechLib:boolean;
- begin
- {$IFC GENERATINGPOWERPC}
- HasSpeechLib := longint(@SpeakString) <> kUnresolvedCFragSymbolAddress;
- {$ELSEC}
- HasSpeechLib := true;
- {$ENDC}
- end;
-
- function SpeechAvailable: boolean;
- var
- v: longint;
- begin
- AssertDidStartup( startup_check );
- {$IFC debug}
- SpeechAvailable := true;
- {$ELSEC}
- SpeechAvailable := (Gestalt(gestaltSpeechAttr, v) = noErr) & BTST(v, gestaltSpeechMgrPresent) & HasSpeechLib;
- {$ENDC}
- end;
-
- function SpeakBusy: boolean;
- begin
- AssertDidStartup( startup_check );
- {$IFC debug}
- SpeakBusy := false;
- {$ELSEC}
- SpeakBusy := SpeechAvailable & (SpeechBusy > 0);
- {$ENDC}
- end;
-
- procedure SpeakStr (s: Str255);
- begin
- AssertDidStartup( startup_check );
- {$IFC debug}
- DebugStr(concat('Speak ', s));
- {$ELSEC}
- if not SpeechAvailable | (SpeakString(@s) <> noErr) then begin
- SysBeep(1);
- end;
- {$ENDC}
- end;
-
- procedure Speak (id, index: integer);
- var
- s: Str255;
- begin
- AssertDidStartup( startup_check );
- GetIndString(s, id, index);
- SpeakStr(s);
- end;
-
- procedure FinishSpeak;
- begin
- {$IFC not debug}
- if SpeechAvailable then begin
- SpeakStr('');
- end;
- {$ENDC}
- end;
-
- procedure StartupSpeak;
- begin
- DidStartup( startup_check );
- SetStartup(nil, nil, 0, FinishSpeak);
- end;
-
- end.